import { DeleteOutlined } from "@ant-design/icons";
import type { ButtonProps, PopconfirmProps } from "antd";
import { Button, Popconfirm } from "antd";
import React from "react";

// const confirm: PopconfirmProps["onConfirm"] = (e) => {
//   console.log(e);
//   message.success("Click on Yes");
// };

// const cancel: PopconfirmProps["onCancel"] = (e) => {
//   console.log(e);
//   message.error("Click on No");
// };

const App: React.FC<{
  children: React.ReactNode;
  title?: string;
  okText?: string;
  type?: ButtonProps["type"];
  size?: "small" | "middle" | "large";
  cancelText?: string;
  danger?: boolean;
  icon?: React.ReactNode;
  onConfirm?: PopconfirmProps["onConfirm"];
  onCancel?: PopconfirmProps["onCancel"];
  description?: string;
  disabled?: boolean;
  buttonProps?: ButtonProps;
}> = (props) => {
  const {
    children,
    disabled,
    title = "你确定要删除吗？",
    size,
    type,
    danger,
    icon = <DeleteOutlined />,
    description,
    okText,
    cancelText,
    onConfirm,
    onCancel,
    buttonProps,
  } = props;
  return (
    <Popconfirm
      disabled={disabled}
      title={title}
      description={description}
      onConfirm={onConfirm}
      onCancel={onCancel}
      okText={okText}
      cancelText={cancelText}
    >
      <Button
        type={type}
        icon={icon}
        size={size}
        danger={danger}
        disabled={disabled}
        {...buttonProps}
      >
        {children}
      </Button>
    </Popconfirm>
  );
};

export default App;
